-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Also syntheize calls to inherited ToString
.
#18508
C#: Also syntheize calls to inherited ToString
.
#18508
Conversation
…ToString call being synthesized.
6293862
to
bae29ae
Compare
DCA looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.
Files not reviewed (3)
- csharp/ql/test/library-tests/implicittostring/implicitToString.expected: Language not supported
- csharp/ql/test/library-tests/implicittostring/implicitToString.ql: Language not supported
- csharp/ql/test/query-tests/Nullness/Implications.expected: Language not supported
Comments suppressed due to low confidence (2)
csharp/ql/test/library-tests/implicittostring/implicitToString.cs:49
- Ensure that the behavior of the inherited
ToString
method inContainer2
is covered by the test cases.
y = "Hello" + container2; // Implicit Container.ToString call.
csharp/ql/test/library-tests/implicittostring/implicitToString.cs:52
- Ensure that the behavior of the inherited
ToString
method inContainer3
is covered by the test cases.
y = "Hello" + container3; // Implicit Object.ToString call.
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
.GetMembers() | ||
.OfType<IMethodSymbol>() | ||
.Where(method => | ||
method.GetName() == "ToString" && | ||
method.Parameters.Length == 0 | ||
) | ||
.FirstOrDefault(); | ||
|
||
return toString ?? GetToStringMethod(type.BaseType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's odd that we have no helper for getting the base types already. Maybe adding this to SymbolExtensions
would make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the base types are used in all sorts of different ways and I didn't find any overlapping use cases for recursively going through the type hierarchy to find a method.
No description provided.